package com.qdu.servlet;

import com.qdu.entity.Movie;
import com.qdu.service.MovieService;
import com.qdu.service.impl.MovieServiceImpl;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Zom
 */
@WebServlet("/smbs")
public class SearchMvBkServlet extends HttpServlet{
     
    MovieService movieService = new MovieServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1:获取关键字
        String keyword = req.getParameter("keyword");
        //2:调用MovieServiceImpl类的findMoviesByKeyword()方法根据关键字查询电影列表
        List<Movie> mlist = movieService.findMoviesByKeyword(keyword);
        //3:生成动态响应
        req.setAttribute("searchList", mlist);
        req.getRequestDispatcher("/searchList.jsp").forward(req, resp);
    }
    
}
